home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Hacks / Hacks ’92 / Text Capture FKEY / Num_to_hex.c < prev    next >
Text File  |  1995-09-10  |  376b  |  18 lines

  1. void Num_to_hex( long num, StringPtr hex, short numbytes );
  2.  
  3. void Num_to_hex( long num, StringPtr hex, short numbytes )
  4. {
  5.     short    curbyte;
  6.     long    lastnyb;
  7.     
  8.     hex[0] = 2 * numbytes;
  9.     for (curbyte = hex[0]; curbyte > 0; --curbyte)
  10.     {
  11.         lastnyb = num & 0x0000000FL;
  12.         if (lastnyb < 10)
  13.             hex[curbyte] = lastnyb + '0';
  14.         else
  15.             hex[curbyte] = lastnyb - 10 + 'A';
  16.         num >>= 4;
  17.     }
  18. }